<?php
/*********************/
/*                   */
/*  Version : 5.1.0  */
/*  Author  : RM     */
/*  Comment : 071223 */
/*                   */
/*********************/

class SystemFrameWork extends FrameWork
{

	public $sysmenu = array( );
	public $obj_system_power = NULL;

	public function SystemFrameWork( $errorlevel = "", $contenttype = "" )
	{
		parent::setframework( $errorlevel = "", $contenttype = "" );
		$this->setsubtemplates( $this->_configinfo['websit']['systemadmin'] );
		$this->_getLangType( );
		$this->_objsmarty->caching = false;
		$this->clearAssign( "template_dir" );
		$this->_objsmarty->assign( "template_dir", $this->_configinfo['websit']['site_url']."/templates" );
		//$this->checkAuthorization( );
		require_once( "system_power.class.php" );
		$this->checkSysMember( );
		$this->publicModule( );
		$this->memberAccp( );
		$this->checkStatics( );
		$this->_input = $this->_param_unescape( $this->_input, $this->_configinfo['websit']['ncharset'] );
	}

	public function _param_unescape( $_obfuscate_nMEBVM4, $_obfuscate_uLkyO3l5Qw )
	{
		if ( is_array( $_obfuscate_nMEBVM4 ) )
		{
			foreach ( $_obfuscate_nMEBVM4 as $_obfuscate_5w => $_obfuscate_6A )
			{
				if ( is_array( $_obfuscate_6A ) )
				{
					$_obfuscate_nMEBVM4[$_obfuscate_5w] = $this->_param_unescape( $_obfuscate_6A, $_obfuscate_uLkyO3l5Qw );
				}
				else
				{
					$_obfuscate_nMEBVM4[$_obfuscate_5w] = Common::unescape( $_obfuscate_6A, $_obfuscate_uLkyO3l5Qw );
				}
			}
			return $_obfuscate_nMEBVM4;
		}
		return $_obfuscate_nMEBVM4;
	}

	public function navmenu( )
	{
		$_obfuscate_yrn92uo1 = array(
		  //首页tab
			array(
				"name" => $this->_lang['langSysCIndex'],
				"power" => "index",
				"body" => array(
					array(
						"name" => $this->_lang['langSysCSystemIndex'],
						"power" => "index~9999",
						"url" => "index.php?action=index_info"
					)
				)
			),
			//系统tab
			array(
				"name" => $this->_lang['langSysCSystemSet'],
				"power" => "system",
			//左边menu
				"body" => array(
			         //基本设置
					array(
						"name" => $this->_lang['langSysCBasicSet'],
						"power" => "system_baseinfo~1001",
						"url" => "baseinfo.manage.php?action=list"
					),
					//新闻管理
					array(
						"name" => $this->_lang['langSysCNews'],
						"power" => "system_news~1002",
						"url" => "news.manage.php?action=list"
					),
					//邮件模板
					array(
						"name" => $this->_lang['langSysCEmailTemplate'],
						"power" => "system_email~1003",
						"url" => "mailcontent.manage.php?action=list"
					),
					//基本栏目
					array(
						"name" => $this->_lang['langSysCBasicCote'],
						"power" => "system_section~1004",
						"url" => "section.manage.php?action=list"
					),
					//权限组
					array(
						"name" => $this->_lang['langSysCPowerGroup'],
						"power" => "system_power_group~1005",
						"url" => "system_power.manage.php?action=list_group"
					),
					//管理员
					array(
						"name" => $this->_lang['langSysCAdmin'],
						"power" => "system_power_member~1006",
						"url" => "system_power.manage.php?action=member"
					),
					//支付接口
					array(
						"name" => $this->_lang['langSysCPayment'],
						"power" => "system_alipay~1007",
						"url" => "payment.manage.php?action=list"
					),
					//用户协议
					array(
						"name" => $this->_lang['langSysCUserAgreement'],
						"power" => "system_agreement~1008",
						"url" => "agreement.manage.php?action=list"
					),
					//频道管理
					array(
						"name" => $this->_lang['langSysCChannelManage'],
						"power" => "system_channel~1009",
						"url" => "channel.manage.php?action=list"
					),
					//首页管理
//delete by shenfu on 20091117
//					array(
//						"name" => $this->_lang['langSysCChannelIndexManage'],
//						"power" => "system_channel_index~1010",
//						"url" => "channel.manage.php?action=index_set"
//					),
					//汇率管理
//					array(
//						"name" => $this->_lang['langSysCExchange'],
//						"power" => "system_exchange~1011",
//						"url" => "exchange.manage.php?action=list"
//					),
					//多语言管理
//					array(
//						"name" => $this->_lang['langSysCLanguage'],
//						"power" => "system_exchange~1012",
//						"url" => "language.manage.php?action=list"
//					),
//delete by shenfu on 20091117
					//开店协议
					array(
						"name" => $this->_lang['langSysShopAgreement'],
						"power" => "system_shop_agreement~1013",
						"url" => "shop_agreement.manage.php?action=list"
					),
					//积分设置
					array(
						"name" => $this->_lang['langSysCredits'],
						"power" => "system_credits_set~1014",
						"url" => "credits.manage.php?action=list"
					)
				)
			),
			array(
				"name" => $this->_lang['langSysCProductManage'],
				"power" => "product",
				"body" => array(
					array(
						"name" => $this->_lang['langSysCProductClass'],
						"power" => "product_category~1101",
						"url" => "pclass.manage.php?action=manage"
					),
					array(
						"name" => $this->_lang['langSysCProductAttribute'],
						"power" => "product_attribute~1102",
						"url" => "attribute.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCProductList'],
						"power" => "product_product~1103",
						"url" => "product.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCAutoAddPrice'],
						"power" => "product_up_price~1104",
						"url" => "up_price.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCProductStatic'],
						"power" => "product_html~1105",
						"url" => "product.html.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCProductBrand'],
						"power" => "product_brand~1106",
						"url" => "product_brand.manage.php?action=list"
					)
				)
			),
			array(
				"name" => $this->_lang['langSysCDealManage'],
				"power" => "transaction",
				"body" => array(
					array(
						"name" => $this->_lang['langSysCDealForm'],
						"power" => "transaction_order~1201",
						"url" => "order.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCLawManage'],
						"power" => "transaction_complaint~1202",
						"url" => "complaint.manage.php?action=complaint"
					),
					array(
						"name" => $this->_lang['langSysCComplaintManage'],
						"power" => "transaction_report~1202",
						"url" => "complaint.manage.php?action=report"
					)
				)
			),
			array(
				"name" => $this->_lang['langSysCMemberManage'],
				"power" => "member",
				"body" => array(
					array(
						"name" => $this->_lang['langSysCMemberManage'],
						"power" => "member_manage~1301",
						"url" => "member.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCReputablyManage'],
						"power" => "member_score~1302",
						"url" => "score.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCConsigneeAddress'],
						"power" => "member_receive~1303",
						"url" => "receive.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCProductMessage'],
						"power" => "member_product_message~1304",
						"url" => "productmessage.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCShopMessage'],
						"power" => "member_store_shopmessage~1305",
						"url" => "shopmessage.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCMessageGroupSend'],
						"power" => "member_system_message~1306",
						"url" => "message.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysMenuPersonalCertify'],
						"power" => "member_personal_certify~1307",
						"url" => "member_personal_certify.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysMemberGroup'],
						"power" => "member_group~1308",
						"url" => "member_group.manage.php?action=list"
					)
				)
			),
			array(
				"name" => $this->_lang['langSysCShopManage'],
				"power" => "store",
				"body" => array(
					array(
						"name" => $this->_lang['langSysCShopClass'],
						"power" => "store_category~1401",
						"url" => "shopcategory.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCShopList'],
						"power" => "store_shop~1402",
						"url" => "shop.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCShopFirendLink'],
						"power" => "store_shoplink~1403",
						"url" => "shoplink.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCShopProductClass'],
						"power" => "store_shopproductcate~1404",
						"url" => "shopproductcate.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCShopAttestation'],
						"power" => "store_entityCheck~1405",
						"url" => "shopentity.manage.php?action=list"
					)
				)
			),
			//工具tab
			array(
				"name" => $this->_lang['langSysCSystemTool'],
				"power" => "tools",
				"body" => array(
					array(
						"name" => $this->_lang['langSysCZoneManage'],
						"power" => "tools_area~1711",
						"url" => "area.manage.php"
					),
					array(
						"name" => $this->_lang['langSysCStaticManage'],
						"power" => "tools_channel~1701",
						"url" => "html.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCKeyWordManage'],
						"power" => "tools_keyword~1702",
						"url" => "keyword.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCKeennessWordFiltrate'],
						"power" => "tools_filter~1710",
						"url" => "filter.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCAdvManage'],
						"power" => "tools_adv~1703",
						"url" => "advertisement.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCVoteSurvey'],
						"power" => "tools_vote~1704",
						"url" => "vote.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCFirendLink'],
						"power" => "tools_link~1705",
						"url" => "link.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCDatabase'],
						"power" => "tools_database_backup~1706",
						"url" => "sqlback.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysCOperatorNote'],
						"power" => "tools_power_log~1707",
						"url" => "system_power.manage.php?action=all_log"
					),
					//通行证
//delete by shenfu on 20091117
//					array(
//						"name" => $this->_lang['langSysCLaissezPasser'],
//						"power" => "tools_integration~1708",
//						"url" => "integration.manage.php?action=manage"
//					),
					//会员整合
//					array(
//						"name" => $this->_lang['langSysCMemberConformity'],
//						"power" => "tools_conformitymember~1709",
//						"url" => "conformitymember.manage.php?action=manage"
//					),
//delete by shenfu on 20091117
					array(
						"name" => $this->_lang['langSysCAccessStat'],
						"power" => "tools_statistic~1712",
						"url" => "statics.manage.php?action=list"
					)
				)
			),
			array(
				"name" => $this->_lang['langSysCFinanceManage'],
				"power" => "finance",
				"body" => array(
					array(
						"name" => $this->_lang['langSysCPredepositManage'],
						"power" => "finance_predeposit~1801",
						"url" => "predeposit.manage.php?action=list"
					),
					array(
						"name" => $this->_lang['langSysMenuShopPay'],
						"power" => "finance_shoppay~1802",
						"url" => "shop_pay.manage.php?action=list"
					)
				)
			),
			array(
				"name" => $this->_lang['langSysApp'],
				"power" => "app",
				"body" => array(
					array(
						"name" => $this->_lang['langSysAppList'],
						"power" => "app_list~1901",
						"url" => "app_module.manage.php?action=list"
					)
				)
			)
		);
		return $_obfuscate_yrn92uo1;
	}

	public function publicModule( )
	{
		$_obfuscate_yrn92uo1 = $this->navmenu( );
		if ( $_SESSION['s_admin'] != "" )
		{
			$_obfuscate_D2wpsVABtdp6 = array( );
			foreach ( $_obfuscate_yrn92uo1 as $_obfuscate_Vwty => $_obfuscate_VgKtFeg )
			{
				if ( is_array( $_SESSION['s_admin']['power'] ) )
				{
					foreach ( $_SESSION['s_admin']['power'] as $_obfuscate_hgei5uBj )
					{
						if ( $_obfuscate_VgKtFeg['power'] == $_obfuscate_hgei5uBj )
						{
							$_obfuscate_D2wpsVABtdp6[] = $_obfuscate_VgKtFeg;
						}
					}
				}
			}
			$_obfuscate_Il8i = $_SERVER['REQUEST_URI'];
			foreach ( $_obfuscate_D2wpsVABtdp6 as $_obfuscate_Vwty => $_obfuscate_VgKtFeg )
			{
				if ( !empty( $_obfuscate_VgKtFeg['body'] ) )
				{
					$_obfuscate_kGWeXKIHuJ2 = array( );
					foreach ( $_SESSION['s_admin']['power'] as $_obfuscate_hgei5uBj )
					{
						$_obfuscate_ZpkFVISdgIl6zahomQ = array( );
						foreach ( $_obfuscate_VgKtFeg['body'] as $_obfuscate_dfzK7LWi )
						{
							if ( $_obfuscate_hgei5uBj == $_obfuscate_dfzK7LWi['power'] )
							{
								$_obfuscate_jq3moiI = $this->matchUrl( $_obfuscate_dfzK7LWi['url'], $_obfuscate_Il8i );
								if ( $_obfuscate_jq3moiI == 1 )
								{
									$_obfuscate_dfzK7LWi['now_page'] = "1";
									$_obfuscate_D2wpsVABtdp6[$_obfuscate_Vwty]['now_cate'] = "1";
								}
								else
								{
									$_obfuscate_dfzK7LWi['now_page'] = "0";
								}
								$_obfuscate_kGWeXKIHuJ2[] = $_obfuscate_dfzK7LWi;
							}
						}
					}
					$_obfuscate_D2wpsVABtdp6[$_obfuscate_Vwty]['body'] = "";
					$_obfuscate_D2wpsVABtdp6[$_obfuscate_Vwty]['body'] = $_obfuscate_kGWeXKIHuJ2;
				}
			}
			$this->sysmenu = $_obfuscate_D2wpsVABtdp6;
			$this->output( "navers", $_obfuscate_D2wpsVABtdp6 );
		}
		$this->output( "navers_all", $_obfuscate_yrn92uo1 );
	}

	public function memberAccp( )
	{
		if ( !empty( $_SESSION[s_admin][power] ) )
		{
			$currentFile = substr( strrchr( $_SERVER['PHP_SELF'], "/" ), 1, -4 );
			require_once( BasePath."/system/file_accepttable.php" );
			$acceptNum = FileAccept::file_accept( $currentFile );
			if ( 0 < intval( $acceptNum ) )
			{
				$user_accep_string = preg_replace( "/\\D+/", "|", @implode( "|", $_SESSION['s_admin']['power'] ) );
				$user_accep_array = explode( "|", $user_accep_string );
				if ( !in_array( $acceptNum, $user_accep_array ) )
				{
					echo $error_report = "Sorry! You don't have permission to operate!  <a href='javascript:window.history.back(-1);'>back</a>";
					exit( );
				}
			}
		}
	}

	public function checkSysMember( )
	{
		$this->getlang( "sys_index" );
		if ( $_SESSION['s_admin'] == "" && $this->_input['state'] != 1 )
		{
			$this->output( "url", $this->_configinfo['websit']['site_url'] );
			$this->showpage( "sys_index.login" );
			exit( );
		}
		if ( $this->_input['action'] !== "check_login" )
		{
			if ( !is_object( $this->obj_system_power ) )
			{
				$this->obj_system_power = new SystemPowerClass( );
			}
			$_obfuscate_sPvbZGL4xMq7LVSz = $this->obj_system_power->getSysMemberById( $_SESSION['s_admin']['id'] );
			if ( empty( $_obfuscate_sPvbZGL4xMq7LVSz ) || $_obfuscate_sPvbZGL4xMq7LVSz['sys_password'] !== $_SESSION['s_admin']['password'] )
			{
				$this->output( "url", $this->_configinfo['websit']['site_url'] );
				$this->showpage( "sys_index.login" );
				exit( );
			}
		}
	}

	public function checkAuthorization( )
	{
		$this->getlang( "sys_index" );
		if ( $this->check_powerby == true )
		{
			$_obfuscate_hxiIZ_YZceejzHU = @file_get_contents( BasePath."/templates/".$this->_configinfo['websit']['templatesname']."/head.config.html" );
			if ( preg_match( "/\\<tpl\\>\\s*\\\$HtmlTitle\\s*\\<\\/tpl\\>/", $_obfuscate_hxiIZ_YZceejzHU ) != 1 )
			{
				echo $this->_lang['langSysPowerbyWrong'];
				exit( );
			}
			$_obfuscate_4ZRovmmmXtDsQp4 = @file_get_contents( BasePath."/templates/".$this->_configinfo['websit']['templatesname']."/footer.html" );
			if ( preg_match( "/ShopNC/", $_obfuscate_4ZRovmmmXtDsQp4 ) != 1 )
			{
				echo $this->_lang['langSysPowerbyWrong'];
				exit( );
			}
		}
	}

	public function matchUrl( $_obfuscate_aOOdI9aZNpQ, $_obfuscate_Il8i )
	{
		$_obfuscate_aOOdI9aZNpQ = preg_replace( "/\\?/", "\\?", $_obfuscate_aOOdI9aZNpQ );
		$_obfuscate_aOOdI9aZNpQ = "\\/".$_obfuscate_aOOdI9aZNpQ;
		$_obfuscate_jq3moiI = preg_match( "/".$_obfuscate_aOOdI9aZNpQ."/", $_obfuscate_Il8i );
		return $_obfuscate_jq3moiI;
	}

	public function formatError( $_obfuscate_rixiYSg )
	{
		$_obfuscate_rixiYSg = str_replace( "\n", " ", trim( $_obfuscate_rixiYSg ) );
		$_obfuscate_rixiYSg = str_replace( "\"", "\\\"", trim( $_obfuscate_rixiYSg ) );
		return $_obfuscate_rixiYSg;
	}

	public function checkStatics( )
	{
		if ( !file_exists( "../".$this->_configinfo[stats][datapath]."/".date( "Y" )."/".date( "n" )."/".date( "j" ) ) )
		{
			@file_get_contents( "../home/index.php" );
		}
	}

	public function setsubtemplates( $_obfuscate_ )
	{
		$this->_subtemplates = $_obfuscate_;
		if ( $this->_subtemplates != "" )
		{
			$this->_subtemplates = "/".$this->_subtemplates;
		}
		$this->_objsmarty->template_dir = Templates."/".$this->_subtemplates;
		$this->_objsmarty->compile_dir = Templates."/templates_c";
		$this->_objsmarty->assign( "templates_subpath", "/templates".$this->_subtemplates );
	}

	public function _getLangType( )
	{
		if ( $this->getCookies( "langType" ) != "" )
		{
			$this->_langType = $this->getCookies( "langType" );
		}
		$this->getlang( "common" );
		$this->getlang( "sys_common" );
	}

}

?>
